/* Copyright (c) 2006, 2009, Carl Burch. License information is located in the
 * com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */
 
package com.cburch.logisim.std.io;

import java.util.List;

import com.cburch.logisim.data.Attribute;
import com.cburch.logisim.data.AttributeOption;
import com.cburch.logisim.data.Attributes;
import com.cburch.logisim.data.Direction;
import com.cburch.logisim.tools.FactoryDescription;
import com.cburch.logisim.tools.Library;
import com.cburch.logisim.util.Strings;

public class Io extends Library {
    static final AttributeOption LABEL_CENTER = new AttributeOption("center", "center", Strings.getter("ioLabelCenter", Strings.stdSource));

    static final Attribute ATTR_COLOR = Attributes.forColor("color",
            Strings.getter("ioColorAttr", Strings.stdSource));
    static final Attribute ATTR_LABEL_LOC = Attributes.forOption("labelloc",
            Strings.getter("ioLabelLocAttr", Strings.stdSource),
            new Object[] { LABEL_CENTER, Direction.NORTH, Direction.SOUTH,
                Direction.EAST, Direction.WEST });
    static final Attribute ATTR_LABEL_COLOR = Attributes.forColor("labelcolor",
            Strings.getter("ioLabelColorAttr", Strings.stdSource));
    
    private static FactoryDescription[] DESCRIPTIONS = {
        new FactoryDescription("Button", Strings.getter("buttonComponent", Strings.stdSource),
                "button.gif", "Button"),
        new FactoryDescription("Joystick", Strings.getter("joystickComponent", Strings.stdSource),
                "joystick.gif", "Joystick"),
        new FactoryDescription("Keyboard", Strings.getter("keyboardComponent", Strings.stdSource),
                "keyboard.gif", "Keyboard"),
        new FactoryDescription("LED", Strings.getter("ledComponent", Strings.stdSource),
                "led.gif", "Led"),
        new FactoryDescription("7-Segment Display", Strings.getter("sevenSegmentComponent", Strings.stdSource),
                "7seg.gif", "SevenSegment"),
        new FactoryDescription("Hex Digit Display", Strings.getter("hexDigitComponent", Strings.stdSource),
                "hexdig.gif", "HexDigit"),
        new FactoryDescription("DotMatrix", Strings.getter("dotMatrixComponent", Strings.stdSource),
                "dotmat.gif", "DotMatrix"),
        new FactoryDescription("TTY", Strings.getter("ttyComponent", Strings.stdSource),
                "tty.gif", "Tty"),
    };

    private List tools = null;

    public Io() { }

    public String getName() { return "I/O"; }

    public String getDisplayName() { return Strings.get("ioLibrary", Strings.stdSource); }

    public List getTools() {
        if(tools == null) {
            tools = FactoryDescription.getTools(Io.class, DESCRIPTIONS);
        }
        return tools;
    }
}
